#include "unit.h"
#include "battlefield.h"
#include "graphicsmanager.h"

/* Battlefield Code */
void Unit::BattlefieldDraw(){
	/* Draw Movement */ {
		double x = Position[0] * Battlefield::Tile_Size;
		double y = (Position[1] + 1) * Battlefield::Tile_Size;
		double Move = (Movement.Current * 1.0 / Movement.Maximum) * Battlefield::Tile_Size;

		GraphicsManager::DrawRectangle(x, y, 5.0, -Move, Color(1, 0, 1));
	}

	/* Draw Unit */ {
		double x = Position[0] * Battlefield::Tile_Size + 5;
		double y = Position[1] * Battlefield::Tile_Size + 5;
		double Size = Battlefield::Tile_Size - 10;

		Color c = Color(1, 0, 0);
		if (this->Team == Teams::Player){
			c = Color(0, 0, 1);
		}

		GraphicsManager::DrawRectangle(x - 2, y - 2, Size + 4, Size + 4, c);
		texture->Draw(x, y, Size, Size);
	}
    //texture->Draw(x, y, 32, 32);
}

void Unit::Kill(){
	IsDead = true;
	HP.Current = 0;
}

bool Unit::IsAlive(){
	return !IsDead && HP.Current > 0;
}
